package com.bw.z.mvp.view.people.adapter;

import android.widget.ImageView;

import com.blankj.utilcode.util.TimeUtils;
import com.bw.z.R;
import com.bw.z.mvp.model.entity.FollowEntity;
import com.bw.z.network.Api;
import com.bw.z.utils.GlideUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

import java.util.Date;

public class FollowNewsAdapter extends BaseQuickAdapter<FollowEntity.Values, BaseViewHolder> {

    public FollowNewsAdapter() {
        super(R.layout.item_follow);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, FollowEntity.Values values) {
        Date date = new Date(values.news_time * 1000);
        String timeStr = TimeUtils.getFriendlyTimeSpanByNow(date);

        baseViewHolder.setText(R.id.follow_item_name_tv, values.author_name);
        baseViewHolder.setText(R.id.follow_item_value_tv, values.author_attestation);
        baseViewHolder.setText(R.id.follow_item_title, values.news_title);

        baseViewHolder.setText(R.id.follow_item_time, "" + timeStr);
        ImageView headImg = baseViewHolder.getView(R.id.follow_item_top_img);
        ImageView img = baseViewHolder.getView(R.id.follow_item_img);
        GlideUtils.getInstance().GlideCircleCropImage(Api.FileUrl + values.author_img, headImg);
        GlideUtils.getInstance().GlideImage(Api.FileUrl + values.medias.get(0).media_url, img);
    }
}
